home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_96_getNetTextBehav.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  2.4 KB  |  87 lines

  1. property pNetID, pResult, pStartAction, pExitFrameDone, pWhichEvent, pURL, pTicks, pEndTicks
  2.  
  3. on getPropertyDescriptionList
  4.   set description to [:]
  5.   addProp(description, #pWhichEvent, [#default: #mouseUp, #format: #symbol, #comment: "On Which Event:", #range: [#mouseUp, #exitFrame]])
  6.   addProp(description, #pURL, [#default: "http://<put URL here>         ", #format: #string, #comment: "URL:"])
  7.   addProp(description, #pResult, [#default: 1, #format: #integer, #comment: "Channel number of field:"])
  8.   addProp(description, #pTicks, [#default: 60, #format: #integer, #comment: "Timeout seconds:"])
  9.   return description
  10. end
  11.  
  12. on getBehaviorDescription
  13.   return "GetNetText Behavior"
  14. end
  15.  
  16. on getAssocMembers
  17.   set myPropList to []
  18.   return myPropList
  19. end
  20.  
  21. on beginSprite me
  22.   set pStartAction to 0
  23. end
  24.  
  25. on mouseUp
  26.   if pStartAction = 0 then
  27.     set pNetID to getNetText(pURL)
  28.     cursor(4)
  29.     set pStartAction to 1
  30.     set pEndTicks to pTicks
  31.     set pEndTicks to pEndTicks * 60
  32.     set pEndTicks to the ticks + pEndTicks
  33.   end if
  34. end
  35.  
  36. on prepareFrame me
  37.   if pWhichEvent = #mouseUp then
  38.     finishOperation()
  39.   end if
  40. end
  41.  
  42. on exitFrame me
  43.   if (pWhichEvent = #exitFrame) and (not pExitFrameDone = 1) then
  44.     if not pStartAction = 1 then
  45.       set pNetID to getNetText(pURL)
  46.       cursor(4)
  47.       set pStartAction to 1
  48.       set pEndTicks to pTicks
  49.       set pEndTicks to pEndTicks * 60
  50.       set pEndTicks to the ticks + pEndTicks
  51.     end if
  52.     if pStartAction = 1 then
  53.       finishOperation()
  54.       go(the frame)
  55.     end if
  56.   end if
  57. end
  58.  
  59. on finishOperation me
  60.   if (pStartAction = 1) and (the ticks > pEndTicks) then
  61.     netAbort(pNetID)
  62.     set outputMember to the member of sprite pResult
  63.     set the text of outputMember to "Timeout!"
  64.     set pStartAction to 0
  65.     set pExitFrameDone to 1
  66.     cursor(0)
  67.   else
  68.     if (pStartAction = 1) and (netDone(pNetID) = 1) then
  69.       if not (netError(pNetID) = EMPTY) then
  70.         if (netError() = "OK") or (netError() = "none") then
  71.           set outputMember to the member of sprite pResult
  72.           set the text of outputMember to netTextResult(pNetID)
  73.           set pStartAction to 0
  74.           set pExitFrameDone to 1
  75.           cursor(0)
  76.         else
  77.           set outputMember to the member of sprite pResult
  78.           set the text of outputMember to netError()
  79.           set pStartAction to 0
  80.           set pExitFrameDone to 1
  81.           cursor(0)
  82.         end if
  83.       end if
  84.     end if
  85.   end if
  86. end
  87.